package com.cwj.thread;

/**
 * @author chenwujie
 * @date 2021-03-12 09:11
 */
public class FinalTest {

    private static FinalTest obj;
    private int i;
    private int j;

    public FinalTest(int i, int j) {
        this.i = i;
        this.j = j;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            Thread thread = new Thread() {
                @Override public void run() {
                    FinalTest.write();
                }
            };

            Thread thread2 = new Thread() {
                @Override public void run() {
                    FinalTest.read();
                }
            };

            thread2.start();
            thread.start();
        }
    }
    public static void write(){
        obj = new FinalTest(1, 1);
    }
    public static void read(){
        if(obj != null){
            int a = obj.i;
            int b = obj.j;
            if(a != 1){
                System.out.println("adiff");
            }
            if(b != 1){
                System.out.println("bdiff");
            }

        }
    }

}
